#ifndef _UNIT_H_
#define _UNIT_H_

#include "object.h"

class CL_Sprite;
class CL_SoundBuffer;
class World;

class Unit : public Object
{
public:
	Unit(World *world);
	virtual ~Unit();

	void draw();
	bool update(float time);

	bool HitCheck(CL_CollisionOutline *outline, Object *with);
	bool HitCheck(int x, int y);

	void SetPos(int x, int y);
	void SetDest(int x, int y);
	void SetTurretDest(int x, int y);

	void SetAngle(float angle);
	void SetDestAngle(float angle);
	void SetTurretAngle(float angle);
	void SetDestTurretAngle(float dest_angle);

	bool IsSelected()
	{
		return selected;
	}
	void Select()
	{
		selected = true;
	}
	void Deselect()
	{
		selected = false;
	}

	void SetHP(int new_hp);
	void Damage(int dmg);
	void Fire();

private:
	World *world;

	//Corpse
	CL_Sprite *sprMain;
	CL_Sprite *sprMove;
	CL_Sprite *sprStill;

	//Turret
	CL_Sprite *sprTurret;
	CL_Sprite *sprTurretStill;
	CL_Sprite *sprTurretShooting;
	CL_Sprite *sprTurretReloading;
	CL_Sprite *sprTurretGunFlash;

	CL_CollisionOutline *csprCollision;

	float x, y;
	float dx, dy;
	float delta_x, delta_y;

	float angle;
	float dest_angle, delta_angle;

	float turret_angle;
	float dest_turret_angle, delta_turret_angle;

	float speed, turn_speed, turret_turn_speed;

	bool is_firing;
	bool reverse, selected;

	int hp; //new new new! : ))
};

#endif
